/*************************************************************************
	> File Name: test.c
	> Author: WangYiFei
	> Mail: 824537320@qq.com
	> Created Time: Tue 05 Jan 2021 10:18:29 PM CST
 ************************************************************************/
#include "head.h"

int main() {
    int fd;
    char buff[512] = {0};
    ssize_t nread;
    if ((fd = open("./a.txt", O_CREAT | O_RDONLY)) < 0) {
        perror("open");
        exit(1);
    }

    while ((nread = read(fd, buff, sizeof(buff))) > 0) {
        printf("read %ld\n%s", nread, buff);
        memset(buff, 0, sizeof(buff));
    }

    close(fd);

    return 0;
}
